package com.joysuch.wwyt.api.mh.enums;


public enum MonitPointSendType {

    SOCKET("socket", "socket"), REST("rest", "rest");

    private String code;
    private String name;

    private MonitPointSendType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static MonitPointSendType findByName(String name) {
        MonitPointSendType[] values = MonitPointSendType.values();
        for (MonitPointSendType v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static MonitPointSendType findByCode(String code) {
        MonitPointSendType[] values = MonitPointSendType.values();
        for (MonitPointSendType v : values) {
            if (v.getCode().equals(code)) {
                return v;
            }
        }
        return null;
    }

    public static String findNameByCode(String code) {
        MonitPointSendType types = findByCode(code);
        return types == null ? null : types.name;
    }
}
